package com.tjetc;

import com.alibaba.druid.pool.DruidDataSourceFactory;
import org.junit.jupiter.api.Test;

import javax.sql.DataSource;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * @ author: gaoyongxiang
 * @ date: 2025/8/15
 * @ version: v1.0
 */
public class _7Druid {
    /*
        德鲁伊连接池： druid 强大之处 在于它支持监控
     */
    public static void main(String[] args) throws Exception {
        // 1. 加载maven依赖
        // 2. 加载配置文件
        Properties properties = new Properties();
        InputStream in = _7Druid.class.getClassLoader().getResourceAsStream("druid.properties");
        properties.load(in);
        // 3. 获取连接池对象
        DataSource dataSource = DruidDataSourceFactory.createDataSource(properties);
        System.out.println(dataSource.getClass());
        // 4. 获取连接对象
        System.out.println(dataSource.getConnection());
    }

    @Test
    public void test1() {
        ClassLoader classLoader = _7Druid.class.getClassLoader();
        System.out.println(classLoader.getClass());
    }

}